/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry.samples.jul;

import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.slf4j.MDC;

/**
 * Main
 *
 * @since 2021-06-15
 */
public class Main {
    private static final Logger LOGGER = Logger.getLogger(Main.class.getName());

    private Main() {
    }

    /**
     * main
     *
     * @param args for main
     */
    public static void main(String[] args) {
        LOGGER.config("Hello Sentry!");

        // MDC parameters are converted to Sentry Event tags
        MDC.put("userId", UUID.randomUUID().toString());

        // logging arguments are converted to Sentry Event parameters
        LOGGER.log(Level.INFO, "User has made a purchase of product: %d", 445);

        try {
            throw new IllegalArgumentException("Invalid productId=445");
        } catch (IllegalArgumentException e) {
            LOGGER.log(Level.SEVERE, "Something went wrong", e);
        }
    }
}
